<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form action="<?php echo url_for('contact_person/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getid() : '').'?client_id='.$client_id) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table>
    <tfoot>
      <tr>
        <td colspan="2">
          &nbsp;<a href="<?php echo url_for('mc/show?id='.$client_id) ?>">Cancel</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'contact_person/delete?id='.$form->getObject()->getid(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
          <input type="submit" value="Save" />
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?//php echo $form ?>
			<tr>
		    <td colspan="3">
			   	<?php echo $form['_csrf_token']; ?>
					<?php echo $form['id']; ?>
					<?php echo $form['client_id']; ?>
					<?php echo $form['type']; ?>
					<?php echo $form['author']; ?>
		      <?php echo $form->renderGlobalErrors() ?>
		    </td>
		  </tr>
    </tbody>
  </table>

<table>
	<tr>
		<td valign = 'top' colspan=3>
		<table class='contactpersonTable'>
			<tr>
				<?php echo $form['id']->render(); ?>
				<th><?php echo $form['last_name']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['last_name']->renderError() ?>
	        <?php echo $form['last_name'] ?>
	      </td>
	      <th><?php echo $form['first_name']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['first_name']->renderError() ?>
	        <?php echo $form['first_name'] ?>
	      </td>
	      <th><?php echo $form['middle_name']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['middle_name']->renderError() ?>
	        <?php echo $form['middle_name'] ?>
	      </td>
			</tr>
		
			<tr>
				<th><?php echo $form['contact']['position_title']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['contact']['position_title']->renderError() ?>
	        <?php echo $form['contact']['position_title'] ?>
	      </td>
				<th><?php echo $form['contact']['work_unit']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['contact']['work_unit']->renderError() ?>
	        <?php echo $form['contact']['work_unit'] ?>
	      </td>
			
			</tr>
			<tr>
				<th><?php echo $form['contact']['direct_line_modifier']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['contact']['direct_line_modifier']->renderError() ?>
	        <?php echo $form['contact']['direct_line_modifier'] ?>
	      </td>
				<th><?php echo $form['contact']['direct_line_number']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['contact']['direct_line_number']->renderError() ?>
	        <?php echo $form['contact']['direct_line_number'] ?>
	      </td>
				<th><?php echo $form['contact']['direct_line_extension']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['contact']['direct_line_extension']->renderError() ?>
	        <?php echo $form['contact']['direct_line_extension'] ?>
		        <?php echo $form['contact']['id'] //contact id ?> 
	      </td>
			</tr>
			<tr>
				<td colspan =2 valign=top>
							<fieldset>
								<legend>Email</legend>
								
								<?php foreach($form['emails'] as $formEmail): ?>
						      <?php include_partial('email', array('form'=>$formEmail)); ?>
						    <?php endforeach; ?>
							</fieldset>
				
				</td>
				<td colspan=4>
						<fieldset>
							<legend>Social Media Accounts</legend>
						  <?php foreach($form['socialmediaaccounts'] as $formSMA): ?>
					      <?php include_partial('socialmediaaccountscontact', array('form'=>$formSMA)); ?>
					    <?php endforeach; ?>
						</fieldset>
					
					
				</td>	
			</tr>
		</table>			
		</td>
		<td colspan=2 valign=top>
				<fieldset>
					<legend>Phone</legend>
				  <?php foreach($form['phones'] as $formPhone): ?>
			      <?php include_partial('phonecontact', array('form'=>$formPhone)); ?>
			    <?php endforeach; ?>
				</fieldset>
		</td>	
	</tr>
	<tr>
		<td>
			<fieldset>
					<legend>Websites</legend>
					
				  <?php foreach($form['websites'] as $formWebsite): ?>
			      <?php include_partial('websites', array('form'=>$formWebsite)); ?>
			    <?php endforeach; ?>

			</fieldset>
		</td>
	</tr>
</table>
</form>



<?php slot('submenu') ?>
<ul>
	<li><?php echo link_to(image_tag('contact info.png', array('title'=>"Contact Info", 'width'=>'65px')), 'mc/show?id='.$client_id) ?></li>
	<li><?php echo link_to(image_tag('officers.png', array('title'=>"Officers", 'width'=>'65px')),'officers/index?client_id='.$client_id) ?></li>
	<li><?php echo link_to(image_tag('managementteam.png', array('title'=>"ManagementTeam", 'width'=>'65px')),'management_team/index?client_id='.$client_id) ?></li>
	<li><?php echo link_to(image_tag('companydescription.png', array('title'=>"Company Description", 'width'=>'65px')), 'company_description/index?client_id='.$client_id) ?></li>
	<li><?php echo link_to(image_tag('other note.png', array('title'=>"Other Notes", 'width'=>'65px')), 'mc_note/index?client_id='.$client_id) ?></li>		
</ul>
<?php end_slot() ?>